﻿using System;
using System.Web.UI.WebControls;
using Model;
using Model.Entities;
using MusicSite.ViewClasses;

namespace MusicSite.Views.Content.Track
{
    public partial class IndexTrack : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckAuthentication();
            UserRole roleId = (UserRole)(Session["UserRole"]);
            switch (roleId)
            {
                case UserRole.Administrator:
                    break;
                case UserRole.Registrator:
                    HyperLink admLink1 = (HyperLink)Master.FindControl("adminLink");
                    admLink1.Visible = false;
                    break;
                case UserRole.User:
                    HyperLink admLink = (HyperLink)Master.FindControl("adminLink");
                    admLink.Visible = false;
                    GridViewTrack.Columns[0].Visible = false;
                    hyperLink1.Visible = false;
                    break;
                default:
                    break;
            }
            ErrorName.Visible = false;
            ErrorAlbName.Visible = false;
        }

        protected void GridViewTrack_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            if (e.NewValues["TrackName"] == null)
            {
                ErrorName.Visible = true;
                e.Cancel = true;
            }
            if (e.NewValues["AlbumID"] == null)
            {
                ErrorAlbName.Visible = true;
                e.Cancel = true;
            }
        }
    }
}